package beautiful.butterfly.distributed_task_processing_engine.api;


public abstract class AbstractMultipleTaskDataItemCollectorAndExecuterAndExecuter<TaskDataItem> implements MultipleTaskDataItemCollectorAndExecuterAndExecuter<TaskDataItem>
{
    @Override
    public boolean dealWith(TaskDataItem[] taskDataItems) throws Exception
    {
        if (taskDataItems != null && taskDataItems.length > 0)
        {
            for (TaskDataItem taskDataItem :
                    taskDataItems)
            {
                try
                {
                    dealWith(taskDataItem);
                } catch (NotAllowContinueDealWithTaskDataItemException e)
                {
                    e.printStackTrace();
                    return false;
                } catch (Exception e)
                {
                    e.printStackTrace();
                }
            }
        }
        return true;
    }

    public abstract boolean dealWith(TaskDataItem taskDataItem) throws Exception;

}
